﻿(function ($) {
    app.modals.CreateOrEditSeatInfoModal = function () {
        var _modalManager;

        var _seatInfoService = abp.services.app.seatInfo;

        //$(".maxlength-handler").maxlength({
        //    limitReachedClass: "label label-danger",
        //    alwaysShow: true,
        //    threshold: 5,
        //    placement: 'bottom'
        //});

        var _$seatInfoInformationForm = null;

        this.init = function (modalManager) {
            _modalManager = modalManager;
            _$seatInfoInformationForm = _modalManager.getModal().find("form[name=seatInfoInformationsForm]");

            //渲染select
            $("#alcCodeIdEdit").selectpicker();

            //渲染select
            $("#seatPositionIdEdit").selectpicker();

            //渲染select
            $("#colorIdEdit").selectpicker();

            //渲染select
            $("#materialIdEdit").selectpicker();

            ////渲染select
            //$("#slideEdit").selectpicker();

            ////渲染select
            //$("#hGITEdit").selectpicker();

            ////渲染select
            //$("#lumbarSupportEdit").selectpicker();

            ////渲染select
            //$("#warmerEdit").selectpicker();

            ////渲染select
            //$("#ventlationEdit").selectpicker();

            ////渲染select
            //$("#sABEdit").selectpicker();

            ////渲染select
            //$("#backPocketEdit").selectpicker();

            ////渲染select
            //$("#sBREdit").selectpicker();

            ////渲染select
            //$("#iMSEdit").selectpicker();

            ////渲染select
            //$("#oneTouchEdit").selectpicker();
        }

        this.save = function () {
            if (!_$seatInfoInformationForm.valid()) {
                return;
            }
            //校验通过

            var seatInfo = _$seatInfoInformationForm.serializeFormToObject();
            //console.log(seatInfo);
            //alert(seatInfo[SeatInfo.Slide]);
            _modalManager.setBusy(true);

            _seatInfoService.createOrUpdateSeatInfoAsync({
                seatInfoEditDto: seatInfo
            }).done(function () {
                //提示信息
                abp.notify.info(app.localize('SavedSuccessfully'));
                //关闭窗体
                _modalManager.close();
                //信息保存成功后调用事件，刷新列表
                abp.event.trigger('app.createOrEditSeatInfoModalSaved');
            }).always(function () {
                _modalManager.setBusy(false);
            });
        }
    }
})(jQuery);